package com.luping.xiao.xiao.utils.Thread;

import com.luping.xiao.xiao.domain.SysUser;

import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;

public class ThreadQueue {

    public static EXTRACTOR_STAT currentTaskStat = EXTRACTOR_STAT.WAITSTART;
    /**
     * 已经停止状态等候时间
     */
    public static int waitSeconds = 0;
    public  static int WaitTime=5;

    /**
     * 数据处理状态
     */
    public enum EXTRACTOR_STAT {
        /**
         * 待启动
         */
        WAITSTART,
        /**
         * 数据解析中
         */
        ANALYSIS_RUNNING,
        /**
         * 数据解析完成中
         */
        ANALYSIS_DONE,


        /**
         * 写库中
         */
        STORE_RUNNING,
        /**
         * 写库完成
         */
        STORE_DONE
    }


    /**
     * 无限队列
     */
    private static LinkedBlockingQueue<List<SysUser>> queue = new LinkedBlockingQueue<>();

    public static void addQueue(List<SysUser> sysUser) {
        try {
            queue.put(sysUser);
            ThreadQueue.currentTaskStat=EXTRACTOR_STAT.ANALYSIS_RUNNING;
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }

    /**
     * 获取队列
     *
     * @return
     */
    public static LinkedBlockingQueue<List<SysUser>> gatQueue() {
        return queue;
    }
}
